" Clean html function
" Первичная обработка текста для html публикации
command! -nargs=* Chtml call Chtml()
function! Chtml()
	let s:count = line("$")
	for n in range (1, s:count)
		let s:str = getline(n)
		let s:str = substitute (s:str, "\&", "\\&amp;", "g")
		let s:str = substitute (s:str, "\\(\\s\\)\\(--\\)\\(\\s\\)","\\1\\&mdash;\\3", "g")	
		let s:str = substitute (s:str, "\"", "\\&quot;", "g")
		let s:str = substitute (s:str, "«", "\\&laquo;", "g")
		let s:str = substitute (s:str, "»", "\\&raquo;", "g")
		let s:str = substitute (s:str, "“", "\\&ldquo;", "g")
		let s:str = substitute (s:str, "”", "\\&rdquo;", "g")
		let s:str = substitute (s:str, "„", "\\&bdquo;", "g")
		let s:str = substitute (s:str, "<", "\\&lt;", "g")
		let s:str = substitute (s:str, ">", "\\&gt;", "g")
		call setline(n,s:str)
	endfor
endfunction
